
let moment = require("moment");
import Vue from 'vue';
import * as types from './types';

export default {
  data() {
    return {
      log_msg: '',
      evtbus: new Vue(),
    }
  },
  created() {
    this.evtbus.$on(types.CLEAR_LOG, e=>{
      this.log_msg = '';
    });
  },

  methods: {
    log(msg) {
      let now = moment().format("HH:mm:ss");
      let item = now + " " + msg;
      if(!!!this.log_msg) {
        this.log_msg = item;
      } else {
        this.log_msg += "\n" + item;
      }
    },
  }
}
